<?php
class Apps_View_Helper_VietnameseStripAccent extends Zend_View_Helper_Abstract {
	public function vietnameseStripAccent($string) {
        $string = strtolower($string);
        $string = preg_replace('/à|á|ạ|ả|ã|â|ầ|ấ|ậ|ẩ|ẫ|ă|ằ|ắ|ặ|ẳ|ẵ/', 'a', $string);
        $string = preg_replace('/è|é|ẹ|ẻ|ẽ|ê|ề|ế|ệ|ể|ễ/', 'e', $string);
        $string = preg_replace('/ì|í|ị|ỉ|ĩ/', 'i', $string);
        $string = preg_replace('/ò|ó|ọ|ỏ|õ|ô|ồ|ố|ộ|ổ|ỗ|ơ|ờ|ớ|ợ|ở|ỡ/', 'o', $string);
        $string = preg_replace('/ù|ú|ụ|ủ|ũ|ư|ừ|ứ|ự|ử|ữ/', 'u', $string);
        $string = preg_replace('/ỳ|ý|ỵ|ỷ|ỹ/', 'y', $string);
        $string = preg_replace('/đ/', 'd', $string);
        $string = preg_replace('/!|@|%|\^|\*|\(|\)|\+|\=|\<|\>|\?|\/|,|\.|\:|\;|\'| |\"|\&|\#|\[|\]|~|$|_/', '-', $string);
        $string = preg_replace('/-+-/', '-', $string);
        $string = preg_replace('/^\-+|\-+$/', '', $string);
        $arr    = explode(' ', $string);
        $string = implode('-', $arr);
        return $string;
    }
}
